package com.dynamic.idea.quick.develop.plugin.entity.base;

import com.dynamic.idea.quick.develop.plugin.constants.QuickDevelopConstants;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * 基础的结构信息
 */
public class BaseStructEntity implements Serializable {

    /** 项目基础路径 */
    private String basePath;

    /** 项目名 */
    protected String projectName;

    /** java文件的基础包 默认是 src/main/java */
    private String srcMainJava="src"+ QuickDevelopConstants.FILE_SEPARATOR +"main"+QuickDevelopConstants.FILE_SEPARATOR+"java";

    /** resource文件的基础包 默认是src/main/resources */
    private String srcMainResources="src"+ QuickDevelopConstants.FILE_SEPARATOR +"main"+QuickDevelopConstants.FILE_SEPARATOR+"resources";



    /** 基础包名 */
    protected String basePackageName;

    /** 类名 */
    protected String className;

    /**
     * 得到java的基础包路径
     * @return
     */
    protected String getSrcMainJavaBasePackagePath() {
        return getRealPath(basePath+QuickDevelopConstants.FILE_SEPARATOR+projectName+QuickDevelopConstants.FILE_SEPARATOR+srcMainJava,basePackageName);
    }
    /**
     * 得到resources的基础包路径
     * @return
     */
    protected String getSrcMainResourcesBasePackagePath() {
        return getRealPath(basePath+QuickDevelopConstants.FILE_SEPARATOR+projectName+QuickDevelopConstants.FILE_SEPARATOR+srcMainResources,basePackageName);
    }

    /**
     * 获取真实的路径
     * @param dirPath
     * @param name
     * @return
     */
    protected String getRealPath(String dirPath,String name){
        return dirPath+QuickDevelopConstants.FILE_SEPARATOR+StringUtils.replace(name,".", QuickDevelopConstants.FILE_SEPARATOR);
    }

    // get/set 方法
    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getBasePackageName() {
        return basePackageName;
    }

    public void setBasePackageName(String basePackageName) {
        this.basePackageName = basePackageName;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getSrcMainJava() {
        return srcMainJava;
    }

    public void setSrcMainJava(String srcMainJava) {
        this.srcMainJava = srcMainJava;
    }

    public String getSrcMainResources() {
        return srcMainResources;
    }

    public void setSrcMainResources(String srcMainResources) {
        this.srcMainResources = srcMainResources;
    }

    public String getBasePath() {
        return basePath;
    }

    public void setBasePath(String basePath) {
        this.basePath = basePath;
    }
}
